package script.api.order

import net.sf.json.JSONObject
import script.api.bean.TaxiOrderRequest
import script.api.bean.TaxiOrderResponse
import script.api.db.OrderDaoImpl
import script.api.util.ScriptUtil

/**
 * Created by wb-lj240895 on 2016/11/19.
 */
def excute(request){

    def req = ScriptUtil.getRequestBean(request,TaxiOrderRequest.class) as TaxiOrderRequest;

    def orderId = (Math.random()*100000 - 1).intValue();
    Map order = new HashMap<String, String>();

    if (orderId < 0) orderId = - orderId;
    System.out.println("正在创建订单...orderId:"+ orderId);
    def id = String.valueOf(orderId);

    order.put("eoid",String.valueOf(req.getEoid()));
    order.put("type",String.valueOf(req.getType()));
    order.put("from",String.valueOf(req.getFrom()));
    order.put("flng",String.valueOf(req.getFlng()));
    order.put("flat",String.valueOf(req.getFlat()));
    order.put("to",String.valueOf(req.getTo()));
    order.put("stime",String.valueOf(req.getStime()));
    order.put("pname",String.valueOf(req.getPname()));
    order.put("pmob",String.valueOf(req.getPmob()));
    order.put("bonus",String.valueOf(req.getBonus()));
    order.put("sound",String.valueOf(req.getSound()));
    order.put("geotype",String.valueOf(req.getGeotype()));
    order.put("orderId", id);

    OrderDaoImpl.create(id, order);


    TaxiOrderResponse response = new TaxiOrderResponse()
    response.setOrderId(orderId)
    //注释部分为响应参数错误code
    response.setErr_code(3)
    return response;
}